package springCache;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

@Component
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (bean.getClass() == Dog.class) {
            return new DogProxy((Dog) bean);
        }
        if (bean.getClass() == Cat.class) {
            return new CatProxy((Cat) bean);
        }
        return bean;
    }
}
